package com.xmutca.core.mq.provider;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RabbitMqSender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    @Autowired
    private AmqpTemplate fanoutTemplate;

    @Autowired
    private AmqpTemplate rabbitTemplate;

    /**
     * 点对点
     */
    public void sendDataToCrQueue(Object obj) {
        amqpTemplate.convertAndSend("queue_one_key", obj);
    }

    /**
     * 发送 发布--订阅消息
     */
    public void sendFanoutMsg(Object obj) {
        fanoutTemplate.convertAndSend(obj);
    }

    /**
     * 主题
     */
    public void sendTopicMsg(String topic,Object obj) {
        rabbitTemplate.convertAndSend(topic, obj);
    }
}